package com.yxc.knife4jdemo.common.entity;

import java.time.LocalDateTime;
import java.util.HashMap;

/**
 * @author: YXC
 * @time: 2024/1/9 17:13
 **/
public class R extends HashMap<String, Object> {

    /**
     * 消息
     */
    private String msg;
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 时间戳
     */
    private LocalDateTime timestamp;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public LocalDateTime getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(LocalDateTime timestamp) {
        this.timestamp = timestamp;
    }

    public R() {
        this.msg = "success";
        this.code = 200;
        this.timestamp = LocalDateTime.now();
    }

    public static R ok() {
        return new R();
    }

    public static R ok(Object obj) {
        R r = new R();
        r.put("data", obj);
        return r;
    }

}
